<template>
  <div>
    <!-- 搜索 -->
    <!-- 整车保修期查询 -->
    <TopFilter ref="TopFilterss" :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable ref="table" :columns="columns" :params="fetchParams" :dataSource="dataList" :datakey="'records'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange">
      <template slot="controls" slot-scope="props">
        <multiuse-button size="small" type="primary" icon="el-icon-plus" :click="exportFileBtn.bind()">导出</multiuse-button>
      </template>
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      <multiuse-button type="primary" :click="saveDialog.bind()">保存</multiuse-button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      dialogTitle: '选择车辆',
      visibleAdd: false
    };
  },
  created() {
  },
  methods: {
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    close(){
      this.visible = false;
    },
    chooseOrderNo() {
      this.visible = true;
    },
    // save(obj) {
    //   this.topFilterInit.find(x => x.fieldName == 'model').initialValue = obj[0].address;
    //   this.visible = false;
    // },
    exportFileBtn() {
      this.$refs.TopFilterss.SUBMIT_FORM();
    },saveDialog() {
      this.$refs.formPanel1.SUBMIT_FORM();
      if (this.saveData) {
        this.$emit('save', this.selectedRows);
      }
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    // add() {
    //   this.visibleAdd = true;
    // },
    // closeAdd() {
    //   this.visibleAdd = false;
    //   this.fetchParams = { ...this.fetchParams };
    // },
    // saveAdd() {
    //   this.visibleAdd = false;
    //   this.fetchParams = { ...this.fetchParams };
    // }
    //搜索数据
    topFilterInitFun() {
      return [
         { type: 'INPUT', label: '车型代码', fieldName: 'modelId', placeholder: '请输入', initialValue: '' },
         { type: 'INPUT', label: '车型名称', fieldName: 'modelId', placeholder: '请输入', initialValue: '' }
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '车型', dataIndex: 'partName', sorter: true },
        { title: '品牌', dataIndex: 'vpType', sorter: true }
      ];
    }
  }

};
</script>

<style lang="less" scoped></style>
